home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Utilities
/
Execute Cmd On List
< prev
next >
Wrap
Text File
|
1995-12-19
|
1KB
|
46 lines
#include <Strings as Lists>
// HR, 12/19/95. Version 1.1. Added ExecuteCmdOnQuotedList function.
// ExecuteCmdOnList(cmdTemplate, list)
// Executes the specified command on each item in the list.
// list is a semicolon-separated list of items, usually wave names.
// cmdTemplate is an Igor command with "%s" in place of the item.
// NOTE: %s may occur only once in cmdTemplate.
// Example:
// Make wave0=x, wave1=2*x; ExecuteCmdOnList("AppendToGraph %s", "wave0;wave1")
//
// If the list consists of wave names or data folder names that may be liberal names,
// call ExecuteCmdOnQuotedList instead of ExecuteCmdOnList.
Function ExecuteCmdOnList(cmdTemplate, list)
String cmdTemplate
String list
String theItem // the item to operate on
Variable index=0
String cmd
do
theItem= GetStrFromList(list, index, ";")
if (strlen(theItem) == 0)
break // ran out of items
endif
sprintf cmd, cmdTemplate, theItem
Execute cmd
index += 1
while (1) // loop until break above
End
// ExecuteCmdOnQuotedList(cmdTemplate, list)
// Use this instead of ExecuteCmdOnList if the list contains wave or data folder names.
// It creates a local copy of the list, adding single quotes for liberal names and then
// calls ExecuteCmdOnList.
Function ExecuteCmdOnQuotedList(cmdTemplate, list)
String cmdTemplate
String list
String quotedList = PossiblyQuoteList(list, ";")
ExecuteCmdOnList(cmdTemplate, quotedList)
End